home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / cstdio.arc / SRC.ARC / MOVE.A < prev    next >
Text File  |  1984-12-27  |  888b  |  46 lines

  1. ;    move.a - intrasegment move.
  2. ;    (C) Copyright 1984 Cray Research Inc. - All Rights Reserved.
  3. ;    G. R. Mansfield.  84/12/26.
  4. ;    Ver 1.0-4C27.
  5.  
  6.  
  7.     cseg
  8.     public    _move_
  9.  
  10.  
  11. ;    move(count, s, d)    /* intrasegment move */
  12. ;    SEGSIZE count;    /* number of bytes to move */
  13. ;    BYTE *s, *d;    /* source, destination */
  14.  
  15. _move_:
  16.     mov    bx,sp
  17.     mov    cx,[bx+2]    ; count
  18.     jcxz    mve2        ; if nothing to move
  19.     mov    si,[bx+4]    ; source offset
  20.     mov    di,[bx+6]    ; destination offset
  21.     push    ds
  22.     pop    es
  23.  
  24.     cmp    si,di        ; compare addresses
  25.     jz    mve2        ; if null move
  26.     ja    mve3        ; if (source > destination), no overlap
  27.     std            ; move from end of region
  28.     add    si,cx
  29.     add    di,cx
  30.     dec    si
  31.     dec    di
  32.     shr    cx,1
  33.     jnb    mve1        ; move byte if necessary
  34.     movsb
  35. mve1:    dec    si
  36.     dec    di
  37.     repz movsw
  38.     cld
  39. mve2:    ret
  40.  
  41. mve3:    shr    cx,1        ; move from start of region
  42.     repz movsw
  43.     jnb    mve4        ; move remaining byte
  44.     movsb
  45. mve4:    ret
  46.